package sundun.sharding.scaner;



import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zxl
 * @Description:
 * @date 2025/2/6 12:44
 */
public class InvokerManager {
    private static Map<String, Invoker> INVOKER_MAP = new ConcurrentHashMap<>();


    public synchronized static void addInvoker(String mark, Invoker invoker) {
        Invoker map = INVOKER_MAP.get(mark);
        if (map == null) {
            INVOKER_MAP.put(mark, invoker);
        } else {
            if (INVOKER_MAP.containsKey(mark)) {
                throw new RuntimeException(mark + ":处理器重复");
            }
        }
    }

    public static Invoker getInvoker(String mark) {
        return INVOKER_MAP.get(mark);
    }

}
